package mathcad.matrice;

import com.Ostermiller.util.CSVParser;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.util.Arrays;
import java.util.Scanner;

public class RWFile {

    public static void writeTextToFile(String texttowrite, String fileadress) {
        try {
            FileWriter fw = new FileWriter(fileadress, false);
            BufferedWriter output = new BufferedWriter(fw);
            output.write(texttowrite);
            output.flush();
            output.close();
        } catch (IOException ioe) {
            System.out.println("error " + ioe);
        }
    }

    public static String[] readTextFromFile(String adressedufichier) throws FileNotFoundException, IOException {
        String[] lines = new String[ 6 ];
        Scanner scanner = new Scanner(new File(adressedufichier));
        int L = 0;
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            lines[L] = line;
            L++;
//            System.out.println(line);
        }

        scanner.close();


        return lines;
    }
}
